package com.fh.shop.api.util;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class SMSCodeUtil {
    public static final String APPKEY = "ef0276f768e725ea78846e7c10d0949c";
    public static final String APPSECRET = "68fdc88d3132";
    public static final String URL = "https://api.netease.im/sms/sendcode.action";

    public static String smsCode(String phone){
        //请求头
        Map<String,String> headMap = new HashMap<>();
        headMap.put("AppKey",APPKEY);
        String nonce = UUID.randomUUID().toString();
        headMap.put("Nonce",nonce);
        String time = new Date().getTime() + "";
        headMap.put("CurTime",time);
        headMap.put("CheckSum",CheckSumBuilder.getCheckSum(APPSECRET,nonce,time));

        //传递的参数
        Map<String,String> paramMap = new HashMap<>();
        paramMap.put("mobile",phone);  //手机号
//        paramMap.put("templateid","19510940"); //语音验证码

        //调用方法发送验证码
        String result = HttpClientUtil.postCode(URL, headMap, paramMap);
        return  result;
    }
}
